﻿if (typeof ($) != "undefined") {
    $(document).ready(function () {
        try {
            fun = getPar1("fun");
            deptName = decodeURI(getPar1("deptName"));
            if (fun != "add") {
                $("#txtDeptID").val(deptName);
            }
            if (fun == "view") {
                parent.setButtonHiden();
                $("div input").attr("disabled", true).css("background", "whitesmoke");
                $("div textarea").css("background", "whitesmoke");
                $("div select").attr("disabled", true).css("background", "whitesmoke");
                $("div input[type=button]").hide();
                $("div button").hide();
            }

        }
        catch (Error)
        { }
    });

}

//取得已存在的数据
function GetDept(deptID) {
    var url = "../Extend/AjaxData/jsonlist.aspx?entity=DatDepartment&condition=DeptID='" + deptID + "'";
    $.get(url, function (d, s) {
        var list = eval("(" + d + ")");
        var i = 0;
        if (list.rows.length > 0) {
            for (var o in list.rows) {
                //debugger;
                var t = list.rows[o].ID;
                if (typeof (t) != "undefined") {
                    $("#txtDeptID").val(list.rows[o].DeptName);
                }
            }
        }
        else {
        }
    });

}

var fnCheckData = function () {
    try {
        if ($("#QuestionnaireName").val() == "") {
            return "问卷名不能为空！";
        }
        if ($("#QStyleID").val() == "") {
            return "问卷类型不能为空！";
        }
        if ($("#SubjectSum").val() == "") {
            return "题目数量不能为空！";
        }
        var reg = /^\+?[1-9][0-9]*$/;
        if (reg.test($("#SubjectSum").val()) == false) {
            return "题目数量需要输入非零正整数!";
        }
        //        if ($("#DeptID").val() == "") {
        //            return "发起部门不能为空！";
        //        }
        //        if ($("#QStartTime").val() == "") {
        //            return "问卷开始时间不能为空！";
        //        }
        if ($("#QStartTime").val() != "" && !isDateFormat($("#QStartTime").val())) {
            return "开始日期非日期格式！";
        }
        //        if ($("#QEndTime").val() == "") {
        //            return "问卷结束时间不能为空！";
        //        }
        if ($("#QEndTime").val() != "" && !isDateFormat($("#QEndTime").val())) {
            return "QEndTime非日期格式！";
        }
    }
    catch (e)
     { }
}


/*
//双击事件
function CustomDbClick() {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    document.getElementById("EditUIWindow3").src = "AutoEditUI.aspx?r=" + Math.random() + "&action=check&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID);
    YAHOO.example.container.dialog5.show();
}

//问卷选择题目
var pId;
var conditonId;
var selectId;
var fnChoseeSubject = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    pId = record.getData(const_entityID);
    conditonId = "TrQuestionnaireID";
    selectId = "TrSubjectInfoID";
    
    document.getElementById("EditUIWindow").src = "../EditWidows/YUIMenuList.aspx?masterentity=TrQuestionnaireSubject&search=SubjectType&masterPara=TrSubjectInfo|SubjectName|TrSubjectInfoID";
    YAHOO.example.container.dialog1.show();
}
//问卷详情
var fnSubjectDetail = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    parent.addTabs(record.getData("QuestionnaireName") + '问卷详情', '../../TR/QuestionnaireSubjectList.aspx?id=' + record.getData(const_entityID) + '');
}

*/